package china.accountinghelper.model;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;

public class ModelBook implements Serializable
{
    private static final long serialVersionUID = 1L;

    // 账本的状态，1-启用，0-停用、2-默认账本。
    public static int         STATE_ENABLED    = 1;
    public static int         STATE_DEFAULT    = 2;
    public static int         STATE_DISABLED   = 0;

    // 主键
    private long              mID;
    // 账本名称
    private String            mName;
    // 建立时间
    private Calendar          mCreateTime;
    // 账本状态
    private int               mState;

    
    public ModelBook()
    {
        mID = 0;
        mName = null;
        mCreateTime = null;
        mState = -1;
    }
    
    public long getID()
    {
        return mID;
    }

    public void setID(long pID)
    {
        mID = pID;
    }

    public String getName()
    {
        return mName;
    }

    public void setName(String pName)
    {
        mName = pName;
    }

    public Calendar getCreateTime()
    {
        return mCreateTime;
    }

    public void setCreateTime(Calendar pCreateTime)
    {
        mCreateTime = Calendar.getInstance();
        mCreateTime.setTimeInMillis(pCreateTime.getTimeInMillis());
    }
    public void setCreateTime(Date pCreateTime)
    {
        mCreateTime = Calendar.getInstance();
        mCreateTime.setTimeInMillis(pCreateTime.getTime());
    }
    public void setCreateTime(long pCreateTime)
    {
        mCreateTime = Calendar.getInstance();
        mCreateTime.setTimeInMillis(pCreateTime);
    }
    
    public int getState()
    {
        return mState;
    }

    public void setState(int pState)
    {
        mState = pState;
    }

    @Override
    public String toString()
    {
        return mName;
    }

    @Override
    public int hashCode()
    {
        final int prime = 31;
        int result = 1;
        result = prime * result + (int) (mID ^ (mID >>> 32));
        return result;
    }

    @Override
    public boolean equals(Object obj)
    {
        if (obj == null)
            return false;
        if (this == obj)
            return true;
        if (getClass() != obj.getClass())
            return false;
        ModelBook other = (ModelBook) obj;
        if (mID != other.mID)
            return false;
        return true;
    }

}
